﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using GauntletFramework.Input;
using System.Threading;

namespace GauntletFramework.StateManagment.Loading
{
    public abstract class StateLoading : State
    {
        public StateLoading()
        {
            if (LoadFont == null)
                LoadFont = Game.Content.Load<SpriteFont>(@"GauntletBase\MenuFont");
            
            this.Progress = 0;
            LoadingThread = new Thread(LoadingFunction);
            LoadingThread.Start();
        }

        protected static SpriteFont LoadFont = null;
        protected Thread LoadingThread;
        public int Progress;
        public int Total;
        protected abstract void LoadingFunction();

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            
            SpriteBatch sb = StaticGame.SpriteBatch;

            string loadString = Progress + " / " + Total;
            sb.DrawString(LoadFont, loadString, StaticGame.ScreenCenter - LoadFont.MeasureString(loadString), Color.White);
        }
    }
}
